package com.aisile.yongyouyun.test;

import com.alibaba.fastjson.JSON;
import org.junit.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * @Auther:yry
 * @Date:2024/7/17 0017
 * @VERSON:1.0
 */
public class RestTemplateTestJavaDemoForeryaosu {

    @Test
    public void matchIdentityDemo(){
        RestTemplate restTemplate = new RestTemplate();


        String result =null;
        String url ="https://api.yonyoucloud.com/apis/dst/matchIdentity/matchIdentity";//请求接口地址
        String paramFormat = "form";
        Map<String, Object> params = new HashMap<String, Object>();//请求参数
        params.put("idNumber", "410581200209120539");
        params.put("userName", "郑力源");

        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.add("apicode", "75d1222462474001987f9f441f2918ca");//APICODE
        httpHeaders.add("Content-Type", "application/json");


        HttpEntity<String> httpEntity = new HttpEntity<>(JSON.toJSONString(params),httpHeaders);

        ResponseEntity<Map> responseEntity =  restTemplate.postForEntity(url,httpEntity,Map.class);
        System.out.println(responseEntity);
        System.out.println(responseEntity.getBody());
        System.out.println(responseEntity.getBody().get("code"));

    }



}
